package MeroryTest;

import java.util.ArrayList;
import java.util.List;

/**
 * VM Args：-XX:PermSize=10M -XX:MaxPermSize=10M 将永久代的容量设置为10M
 * JDK1.8彻底移除了永久代，所以代码可以一直执行下去
 * 
 * http://www.coderhelper.top/doc/technotes/tools/windows/java.html#BABDCEGG
 * 
 * -XX:MaxPermSize=size Sets the maximum permanent generation space size (in
 * bytes). This option was deprecated in JDK 8, and superseded by the
 * -XX:MaxMetaspaceSize option.
 * 
 * -XX:PermSize=size Sets the space (in bytes) allocated to the permanent
 * generation that triggers a garbage collection if it is exceeded. This option
 * was deprecated un JDK 8, and superseded by the -XX:MetaspaceSize option.
 */
public class ConstantPoolOutOfMemory {

	public static void main(String[] args) {
		// 使用List保持着常量池引用，避免Full GC回收常量池行为
		List<String> list = new ArrayList<String>();
		int i = 0;
		while (true) {
			list.add(String.valueOf(i++).intern());
		}
	}

}
